package org.vordel.incubator.examples.management_api;

import com.vordel.es.Entity;
import com.vordel.es.EntityStore;
import com.vordel.es.EntityType;

public class RegularExpressionManager extends EntityWrapperManager{

	public static final String RequiredContentRegularExpressionGroup = "Required Content Regular Expressions";
	public static final String ThreatContentRegularExpressionGroup = "Threatening Content Regular Expressions";
	@Override
	protected String getContainerEntityTypeName() {
		// TODO Auto-generated method stub
		return "RegularExpressionGroup";
	}

	@Override
	protected String getContainerEntityName() {
		// TODO Auto-generated method stub
		return "Regular Expression Library";
	}

	@Override
	protected String getEntityTypeName() {
		// TODO Auto-generated method stub
		return "NamedGroup";
	}

	RegularExpressionManager(Session session) {
		super(session);
		// TODO Auto-generated constructor stub
	}

	public RegularExpressionGroup getRegularExpressionGroup(String name) throws Exception {
		
		Entity entity = this.getEntityByName(name);
		return new RegularExpressionGroup(entity,this);
	}
	
	public RegularExpressionAttribute createRegularExpressionAttribute(String name, String expression) throws Exception {
		
		EntityStore es = this.session.getEntityStore();
		EntityType attributeRegularExpression = es.getTypeForName("AttributeRegularExpression");
		
		Entity attributeEntity = new Entity(attributeRegularExpression);
		attributeEntity.setStringField("attributeName", name);
		attributeEntity.setStringField("onceOffRegularExpression", expression);
		
		
		return new RegularExpressionAttribute(attributeEntity, this);
		
	}
}
